/*
date:20210314 pm22:50
key:1.1-9和+/放入字符数组然后全排列，按运算符的位置剔除一些，再以运算符的位置分割出三个部分。
2.		cout << (double)((a * c) + b)/c<<endl;
		return (double)(a * c + b / c);
		第二种没法按小数计算，因此一定要算之前每个部分就double
*/
#include<math.h>
#include <algorithm>
#include <stdio.h>
#include<iostream>
#include<sstream>
#include<stdlib.h>
using namespace std;
const int P = 10007;
void change(int& a, int& b)
{
	int k = b;
	b = a;
	a = k;
}

//split数组的函数
int* split(int* A, int L, int R)
{
	int* B = new int[R - L + 1];
	int j = 0;
	for (int i = L - 1; i < R; i++)
	{
		B[j] = A[i];

		j++;
	}
	return B;
}
//冒泡排序,n决定几趟冒泡，最后n个最大是有序的。
int maopao(int* A, int length, int n)
{
	for (int j = 0; j < n; j++)
	{
		for (int i = 0; i < length - 1 - j; i++)
		{
			if (A[i] > A[i + 1])
			{
				change(A[i], A[i + 1]);
			}
		}
	}
	return A[length - n];
}
int find_big(int a, int b, int c)
{
	if (a + b > a + c)
	{
		if (a > b)
		{
			return a;
		}
		else
		{
			return b;
		}
	}
	else
	{
		if (a > c)
		{
			return a;
		}
		else
		{
			return c;
		}
	}
}
double count(char* A, int jia_p, int chu_p)
{
	//第一部分
	int i,j,a,b,c;
	a = 0;
	b = 0;
	c = 0;
	//a
	i = jia_p; 
	for (j = 0; j<jia_p; j++)
	{		
		a+=int(A[j]-48) * pow(10, i - 1);
		i--;		
	}
	//b
	i = chu_p-jia_p-1;
	for (j = jia_p+1; j < chu_p; j++)
	{
		b += int(A[j] - 48) * pow(10, i - 1);
		i--;
	}
	//c
	i = 10 - chu_p;
	for (j = chu_p + 1; j < 11; j++)
	{
		c += int(A[j] - 48) * pow(10, i - 1);
		i--;
	}

	return (double)((a * c) + b) / (double)c;
}
int main()
{
	int i;
	double n;
	//要求的运算结果
	cin >> n;
	int g = 0;
	bool flag;
	int jia_p, chu_p;
	char num[11] = { '1','2','3','4','5','6','7','8','9','+','/' };
	do
	{

		//避免运算符号在头或者尾
		if (num[0] == '+' || num[0] == '/' || num[10] == '+' || num[10] == '/')
		{
			continue;
		}
		//保证+至少在/前两个位置,且+号前面不超过两位数（前半部分小于一百）
		for (i = 0; i < 11; i++)
		{
			if (num[i] == '+')
			{
				jia_p = i;
			}
			if (num[i] == '/')
			{
				chu_p = i;
			}
		}
		if (chu_p-jia_p>1&&jia_p<3)
		{		
		}
		else
		{
			continue;
		}
		/*for (i = 0; i < 11; i++)
		{
			cout << num[i] << " ";
		}
		*/
		
		if (n == count(num, jia_p, chu_p))
		{
			g++;
		}

		
	} while (next_permutation(num, num + 11));
	cout << g;

}
